﻿using Sunny.UI;


namespace supermarket
{
    internal class form
    {
        public static UIEditForm userform(String t, user user)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddText("name", "姓名", user.name, true);
            option.AddPassword("paw", "密码", user.paw, true);
            option.AddCombobox("Sex", "性别", new[] { "男", "女" },user.sex=="男"?0:1, true, true);
            option.AddInteger("Age", "年龄", user.age);
            option.AddInteger("phone", "电话", Convert.ToInt32(user.phone), true);
            option.AddText("addr", "住址", user.addr, true);
            option.AddSwitch("admin", "是否管理", user.admin == "是" ? true : false, "是", "否");
            return new UIEditForm(option);
        }
        public static UIEditForm supplierform(String t, supplier supplier)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddText("name", "供应商名字", supplier.name, true);
            option.AddInteger("phone", "电话", Convert.ToInt32(supplier.phone), true);
            option.AddText("addr", "住址", supplier.addr, true);
            option.AddText("goods", "主要供应品", supplier.addr, true);
            return new UIEditForm(option);
        }
        public static UIEditForm goodsform(String t, goods goods, string[] suppliers)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddText("name", "商品名称", goods.name, true);
            option.AddInteger("monovalent", "单价（元）", goods.monovalent, true);
            option.AddCombobox("suppliers", "进货商", suppliers, 0, true, true);
            return new UIEditForm(option);
        }
        public static UIEditForm purchasecontrolform(String t, string[] Supplers, string[] goodss)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddCombobox("Supplers", "供应商", Supplers, 0,true,true);
            option.AddCombobox("goods", "商品", goodss, 0, true, true);
            option.AddInteger("mod", "数目", 0);
            return new UIEditForm(option);
        }

        public static UIEditForm goodsSaleForm(String t)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddInteger("mod", "出售数量", 0);
            return new UIEditForm(option);
        }
        public static UIEditForm goodscancelForm(String t)
        {
            UIEditOption option = new UIEditOption();
            option.AutoLabelWidth = true;
            option.Text = t;
            option.AddInteger("quantity", "出售数量", 0);
            option.AddText("reason", "退货原因", "", true);
            return new UIEditForm(option);
        }
    }
}
